package com.sysu.ooad.action;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.Action;
import com.sysu.ooad.entity.Homework;
import com.sysu.ooad.entity.Student;
import com.sysu.ooad.entity.Task;
import com.sysu.ooad.service.TaskService;

@Component
@Scope("prototype")
public class SourceStudentAction extends CommonAction {

	private TaskService taskService;
	private Map<Task, List<Homework> > taskHomeworkMap;
	
	public Map<Task, List<Homework>> getTaskHomeworkMap() {
		return taskHomeworkMap;
	}
	public void setTaskHomeworkMap(Map<Task, List<Homework>> taskHomeworkMap) {
		this.taskHomeworkMap = taskHomeworkMap;
	}
	public TaskService getTaskService() {
		return taskService;
	}
	@Resource
	public void setTaskService(TaskService taskService) {
		this.taskService = taskService;
	}

	@Override
	public String execute() throws Exception {
		Student student = this.findCurrentStudent();
		taskHomeworkMap = taskService.findTaskHomeworkMapByGroup(student.getGroup());
		return Action.SUCCESS;
	}
}
